﻿using DevComponents.DotNetBar;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WorkStation.UI.Controls
{
    public partial class MessageBoxExRobot : Office2007Form
    {
        public List<int> commNew;
        public MessageBoxResult Result { get; set; }
        public MessageBoxExRobot()
        {
            InitializeComponent();
            this.EnableGlass = false;
        }
        public void SetCaption(string caption)
        {
            this.Text = caption;
        }
        public void SetMessage(string message)
        {
            this.l_Message.Text = message;
        }

        public void SetBoxSts(List<int> comm)
        {
            if (comm.Count > 0 && comm.Count >= 4)
            {
                cb_Mark1.Checked = comm[0] == 1;
                cb_Mark2.Checked = comm[1] == 1;
                cb_Mark3.Checked = comm[2] == 1;
                cb_Mark4.Checked = comm[3] == 1;
            }
            commNew = comm;
        }
        public void SetImage(MessageBoxType messageType)
        {
            switch (messageType)
            {
                case MessageBoxType.Info:
                    this.l_Message.Image = Properties.Resources.Information;
                    break;
                case MessageBoxType.Warn:
                    this.l_Message.Image = Properties.Resources.Warn;
                    break;
                case MessageBoxType.Question:
                    this.l_Message.Image = Properties.Resources.Question;
                    break;
            }
        }
        public static List<int> ShowBox(string message, string caption,
           List<int> comm, MessageBoxType messageType,out bool isCancel)
        {
            isCancel = false;
            MessageBoxExRobot box = new MessageBoxExRobot();
            box.SetCaption(caption);
            box.SetMessage(message);
            box.SetBoxSts(comm);
            box.StartPosition = FormStartPosition.CenterParent;
            box.ShowDialog();
            isCancel=box.DialogResult != DialogResult.OK;
            return box.commNew;
        }



        private void btn_Third_Click(object sender, EventArgs e)
        {
            this.Result = MessageBoxResult.Third;
            this.DialogResult = DialogResult.OK;
            List<int> newComm = new List<int> { 1, 1, 1, 1 };
            newComm[0] = cb_Mark1.Checked ? 1 : 0;
            newComm[1] = cb_Mark2.Checked ? 1 : 0;
            newComm[2] = cb_Mark3.Checked ? 1 : 0;
            newComm[3] = cb_Mark4.Checked ? 1 : 0;
            commNew = newComm;
            this.DialogResult= DialogResult.OK;
            this.Close();
        }

   
        private void MessageBoxExRobot_Load(object sender, EventArgs e)
        {
            cb_Mark1.Text = "爪1";//1256
            cb_Mark2.Text = "爪2";//1256
            cb_Mark3.Text = "爪5";//1256
            cb_Mark4.Text = "爪6";//1256
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }

}
